<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:c="http://java.sun.com/jsp/jstl/core">
    <h:head>
        <title>Facelet Title</title>

    </h:head>
    <h:body>
        <ui:composition template="/template.xhtml">
             <ui:define name="title">
             menu
         </ui:define>
         
            
            <ui:define name="content">
                
                   <c:choose>
                            <c:when test="${userBean.curentUser.role == 'ADMIN'}">
                                
                                    <span class="hover" onclick="$('#UserFAQAnswer#{o.id}').arcticmodal()">Добавить елемент меню</span>

        

                                <div style="display: none;">
                                    <div class="b-modal" id="UserFAQAnswer#{o.id}">
                                        <div class="b-modal_close arcticmodal-close">закрыть</div>    
                                        <h:form id="ADDPRODUCTSTOOTDER">
                                            <table>
                                                <tr>
                                                    <td>Наименование</td>
                                                    <td> <h:inputText value="#{productsBean.currentProducts.name}"/></td>
                                                </tr>
                                                <tr>
                                                    <td>Цена</td>
                                                    <td><h:inputText value="#{productsBean.currentProducts.price}"/></td>
                                                </tr>
                                                <tr>
                                                    <td>Тип</td>
                                                    <td>
                                                <h:selectOneListbox value="#{productsBean.currentProducts.prType}">
                                                            <f:selectItem itemValue="MEAT" itemLabel="Мясное  блюдо"/>
                                                            <f:selectItem itemValue="SOUP" itemLabel="Суп"/>
                                                            <f:selectItem itemValue="PIZZA" itemLabel="Пицца"/>
                                                            <f:selectItem itemValue="SALAT" itemLabel="Салат"/>
                                                            <f:selectItem itemValue="DRINKS" itemLabel="Алкоголь"/>
                                              
                                                        </h:selectOneListbox>
                                                    
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>Цена за</td>
                                                    <td><h:inputText value="#{productsBean.currentProducts.unit}"/></td>
                                                </tr>
                                                <tr>
                                                    <td>Описание</td>
                                                    <td><h:inputTextarea rows="5" cols="50" value="#{productsBean.currentProducts.description}"/></td>
                                                </tr>
                                            </table>
                                            <h:commandButton value="submit" action="#{productsBean.addProducts}"/>
                                        </h:form>
                                    </div>
                                </div>
                              
                            </c:when>                          
                        </c:choose>
                
               
               
                <h:dataTable id="userMess" headerClass="table-header" rowClasses="table-row" value="#{productsBean.getAllProducts()}" var="o" >
                    <h:column>
                        <f:facet name="header">Название</f:facet>
                        #{o.name}
                    </h:column>
                    <h:column>
                        <f:facet name="header">Описание</f:facet>
                        #{o.description}
                    </h:column>
                    <h:column>
                        <f:facet name="header">Цена</f:facet>
                        #{o.price}
                    </h:column>
                    <h:column>
                        <f:facet name="header">Цена за</f:facet>
                        #{o.unit}
                    </h:column>
                    <c:if test="#{userBean.curentUser != null}">
                        <h:column>
                            <f:facet name="header"></f:facet>
                            <h:form>
                                <h:inputText value="#{orderBean.count}"/>
                                
                                <h:commandButton value="Заказать"  actionListener="#{orderBean.addProductsToOrder}" >
                                    <f:attribute name="products" value="#{o}" />
                                    <f:attribute name="users" value="#{userBean.curentUser}"/>
                                </h:commandButton>
                            </h:form>
                        </h:column>
                        
                    </c:if>
                </h:dataTable>
                
            </ui:define>
        </ui:composition>
            
</h:body>

</html>
